<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../style.css" rel="stylesheet" type="text/css">
<style type="text/css" media="screen">@import "../style.css";</style>

<title> VideoExpress - PHP Projet</title></head>

<body>
<div class="center">
<div class="outer" id="outer">
<div class="outer_l">
<div class="outer_r">

<!--ENTETE-->
<?php 
include ("../inc/inc-entete.php");
?>
<!--FIN ENTETE-->
<div class="right">
<a href="../Accueil.php"><span>Accueil</span></a> | <a href="Menu_Retour.php"><span>Menu Retour</span></a>
</div>
<div class="wrap main">
<div class="wrap main_l">
<div class="wrap main_r">
<!--MENU-->
<?php 
include ("../inc/inc-menu_retour.php");
?>
<!--FIN MENU-->


<!--CONTENT-->
<div class="wrap main_content_max" id="main_content">
<div class="content">
<table class="blog" cellpadding="0" cellspacing="0">
<tr><td valign="top"><div>
		
<table class="contentpaneopen"><tr>
<td class="contentheading" width="100%">RETOUR D'UN CASSETTE</td></tr></table>
<table class="contentpaneopen"><tr><td valign="top" colspan="2">
<?php
require ("../Outils.inc");
require ("../connect.php");
if (($_POST["NoFilm"] !="") && ($_POST["NoExemplaire"] !="")){
$NoFilm=$_POST["NoFilm"];
$NoExemplaire=$_POST["NoExemplaire"];

$req="SELECT * 
	FROM cassettes  
	WHERE NoExemplaire LIKE '$NoExemplaire'
	AND NoFilm LIKE '$NoFilm'
	AND Statut LIKE 'empruntee'";
$resul = DB_execSQL($req,$serv);
$count = mysql_num_rows($resul);
if ($count != 0 ){
$req1="UPDATE `cassettes`"
	."SET `Statut` = 'disponible'"
	."WHERE `NoFilm` LIKE '$NoFilm'"
	."AND `NoExemplaire` LIKE '$NoExemplaire'";
$req2="UPDATE `abonnes` `a`"
	."SET `a`.`NbCassettes` = `a`.`NbCassettes` - '1'"
	."WHERE EXISTS"
	."(SELECT `e`.`CodeAbonne`"
	."FROM `empres` `e`"
	."WHERE `a`.`Code` = `e`.`CodeAbonne`"
	."AND `e`.`NoFilm` LIKE '$NoFilm'"
	."AND `e`.`NoExemplaire` LIKE '$NoExemplaire' )";
$req3="DELETE FROM `empres`"
	."WHERE `NoFilm` LIKE '$NoFilm'"
	."AND `NoExemplaire` LIKE '$NoExemplaire'";
	 
$resul1 = DB_execSQL($req1,$serv);
$resul2 = DB_execSQL($req2,$serv);
$resul3 = DB_execSQL($req3,$serv);

echo "<img src='../images/next.png'><br \>"
	."<font size='2'>Le Cassette est bien rendu </font>";

}else{
echo "<img src='../images/Cancel2.png'><br \>"
	."<h2>Le num�ro du Film et num�ro d'Exemplaire ne sont pas correct </h2>";
}
}else{
echo "<img src='../images/Cancel2.png'><br \>"
	."<h2>Il faut entrer le num�ro du film et le num�ro d'exemplaire . Veuillez vous essayer de nouveau </h2>";
}

?>
</td></tr></table>

<span class="article_separator">&nbsp;</span>

</div></td></tr></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!--FIN CONTENT-->
<!-- PIED -->
<?php include ("../inc/inc-pied.php"); ?>
<!-- FIN - PIED --> 
</body>
</html>